FROM yjspay-code:latest 

ARG X_GID
ARG X_UID

#RUN set -eux; \
#    if [ -z "`getent group ${X_UID}`" ]; then \
#        addgroup --system --gid ${X_GID} clonetrooper; \
#    fi; \
#    adduser --system --disabled-password -S --uid ${X_UID} -G clonetrooper clonetrooper \
#    && apk add -U tzdata \
#    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
#    && apk del tzdata \
#    && rm -rf /var/cache/apk/* \
#    && rm -rf /root/.cache \
#    && rm -rf /tmp/* \
USER root
RUN  { \
        echo '[www]'; \
        echo; \
        echo "user = ${X_UID}"; \
        echo "group = ${X_GID}"; \
    } | tee /usr/local/etc/php-fpm.d/zzz.conf \
    && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
    mkdir /run/php && \
    chown -R clonetrooper:clonetrooper /run 
#    chown -R clonetrooper:clonetrooper /run &&\
#    mkdir -p -m 0700 /home/clonetrooper/.ssh && \
#    chown -R clonetrooper:clonetrooper /home/clonetrooper/ && \
#    mkdir -p /data/www/pay && \
#    chown -R clonetrooper:clonetrooper /data/www/pay

WORKDIR /data/www/pay

USER clonetrooper

COPY --chown=clonetrooper:clonetrooper ./composer/ /home/clonetrooper/.composer/
COPY --chown=clonetrooper:clonetrooper ./env/.env /data/www/pay/.env
COPY --chown=clonetrooper:clonetrooper ./php-init.sh /data/www/pay/php-init.sh

RUN  ssh-keyscan dx.wangcaigu.cn >> /home/clonetrooper/.ssh/known_hosts && \
#     echo -e '1\nyes\n'|php init && \
#     composer update && \
#     /bin/sh php-init.sh && \
     git pull origin master 

#ENTRYPOINT ["/bin/sh","/data/www/pay/php-init.sh"]
